package com.hanhai.zrb.backend.web.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.hanhai.common.web.controller.BaseController;
import com.hanhai.zrb.api.biz.service.UserFollowService;

@Controller
@RequestMapping("userfollow")
public class UserFollowController extends BaseController{
	@Resource
	private UserFollowService userFollowService;
	
	@RequestMapping("showFollowPage")
	public String showFollowPage(Long uid,Model model){
		model.addAttribute("uid", uid);
		return "userfollow/showFollowPage";
	}
	
	@RequestMapping("followingListPage")
	public void followingListPage(@RequestParam Long fromUserId,Integer page, Integer rows, HttpServletResponse response){
		if(page==null || page<0){
			page=1;
		}
		if(rows == null || rows<0){
			rows=10;
		}
		PageInfo pageInfo=userFollowService.followingListPage(fromUserId,page, rows);

		super.jsonPage(response, pageInfo);
	}
	
	@RequestMapping("followedListPage")
	public void followedListPage(@RequestParam Long toUserId,Integer page, Integer rows, HttpServletResponse response){
		if(page==null || page<0){
			page=1;
		}
		if(rows == null || rows<0){
			rows=10;
		}
		PageInfo pageInfo=userFollowService.followedListPage(toUserId,page, rows);

		super.jsonPage(response, pageInfo);
	}
	
}
